package cn.kgc.springcloud.controller;

import cn.kgc.springcloud.entity.Group;
import cn.kgc.springcloud.service.GroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: mosin
 * @version: v1.0  2022/6/15
 */
@RestController
@RequestMapping("groups")
public class GroupController {
    @Autowired
    private GroupService groupService;

    @GetMapping
    public List<Group> test01(){
        List<Group> all = groupService.findAll();
        return all;
    }


    @PostMapping
    public Group test02(@RequestBody Group group){

        return groupService.addGroup(group);
    }

    @GetMapping("{id}")
    public Group getById(@PathVariable("id") Integer id){

        return groupService.getById(id);
    }

}
